<template>
  <div>
    <div class="dingdan">
      <div class="header">我的订单</div>

      <!-- 我的订单--------------------------------------------------->

      <div class="con" v-for="(item, index) in list" :key="index">
        <div class="con-header">
          <span class="time">{{ item.ticketTime | timeFilter }}</span>
          <span class="num">猫眼订单号:{{ item.ticketCard }}</span>
          <span class="tu" @click="del(item.ticketId)">
            <i class="el-icon-delete"></i>
          </span>
        </div>
        <div class="con-item">
          <div class="tu1">
            <img
              src="https://p1.meituan.net/movie/f6ec2a022d3644ef493f881d359f65303190471.jpg@66w_91h_1e_1c"
              alt=""
            />
          </div>
          <div class="dian">
            <p class="title">{{ item.film.filmName }}</p>
            <p class="dizhi">{{ item.film.language.languageName }}</p>
            <p class="jihao">
              <span>{{ item.sess.hall.hallName }}</span>
              <span>3排5座</span>
              <span>3排4座</span>
            </p>
            <p class="show-time">{{ item.sess.endTime | timeFilter }}</p>
          </div>
          <div class="qian">￥{{ item.sess.price }}</div>
          <div class="over" v-show="!item.ticketType">已完成</div>
          <div class="over nopay" v-show="!!item.ticketType" @click="toOrder">
            待付款
          </div>

          <div class="del" @click="lookxiangqing">查看详情</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import dingdanInfo from "../../model/dingdan";
export default {
  data() {
    return {
      flag: false,
      list: [],
    };
  },
  methods: {
    lookxiangqing() {
      // this.$router.push({ name: "Film" });
      this.$router.push({ name: "Order" });
    },
    toOrder() {
      this.$router.push({ name: "Order" });
    },
    del(ticketId) {
      // console.log();
      this.list = this.list.filter((item) => item.ticketId != ticketId);
    },
  },

  created() {
    // let userid = window.localStorage.getItem("userid");
    dingdanInfo
      .query({
        // userid,
        id: 1,
      })
      .then((res) => {
        console.log(res);
        this.list = res.data.data;
        // console.log(this.list);
      });
  },

  filters: {
    timeFilter(val) {
      // console.log(typeof val);
      // return val.getFullYear();
      return val.slice(0, 10);
    },
  },
};
</script>
<style scoped lang="scss">
.dingdan {
  width: 1000px;
  overflow: hidden;
  padding-left: 40px;
  box-sizing: border-box;

  .header {
    height: 77px;
    width: 100%;
    // background: pink;
    color: #ec443f;
    font-size: 18px;
    line-height: 77px;
    border-bottom: 1px solid #e1e1e1;
    margin-bottom: 30px;
  }
}

.con {
  width: 880px;
  height: 187px;
  //   background: skyblue;
  border: 1px solid #e5e5e5;
  margin-bottom: 25px;

  .con-header {
    width: 100%;
    height: 50px;
    background: #f7f7f7;
    position: relative;

    .time {
      font-size: 14px;
      color: #333;
      margin-right: 30px;
      line-height: 50px;
      overflow: hidden;
      padding-left: 20px;
      box-sizing: border-box;
    }
    .num {
      font-size: 14px;
      color: #999;
      line-height: 50px;
    }
    .tu {
      margin-left: 820px;
      position: absolute;
      left: 0px;
      top: 15px;
    }
  }
  .con-item {
    width: 100%;
    height: 137px;
    // background: plum;
    overflow: hidden;

    .tu1 {
      width: 66px;
      height: 137px;
      float: left;
      overflow: hidden;
      margin-left: 20px;
      margin-right: 4px;
      img {
        width: 66px;
        height: 91px;
        margin-top: 20px;
      }
    }
    .dian {
      height: 100%;
      width: 427px;
      float: left;
      padding-left: 10px;
      box-sizing: border-box;
      overflow: hidden;
      .title {
        font-size: 16px;
        font-weight: 700;
        color: #333;
        margin-top: 20px;
        margin-bottom: 6px;
      }
      .dizhi {
        font-size: 12px;
        color: #999;
        margin-bottom: 4px;
      }
      .jihao {
        font-size: 12px;
        color: #999;
        margin-bottom: 4px;

        span {
          margin-right: 4px;
        }
      }
      .show-time {
        font-size: 12px;
        color: #f03d37;
      }
    }
  }
}

.qian {
  float: left;
  width: 103px;
  height: 100%;
  line-height: 137px;
  font-size: 14px;
  color: #333;
}

.over {
  width: 129px;
  height: 137px;
  float: left;
  font-size: 14px;
  color: #333;
  line-height: 137px;
  padding-left: 20px;
  box-sizing: border-box;
}
.nopay {
  color: red;
  cursor: pointer;
}
.del {
  float: left;
  width: 70px;
  height: 137px;
  line-height: 137px;
  font-size: 14px;
  color: #333;
  margin-left: 30px;
}
</style>